﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GrayParrot.Web.Controls
{
    [Serializable]
    public class ColumnFilters<T> : List<ColumnFilter>
        where T : IEqualityComparer<ColumnFilter>, new()
    {
        T m_comparer = default(T);

        /// <summary>
        /// Initializes a new instance of the <see cref="Options"/> class.
        /// </summary>
        public ColumnFilters()
        {
            m_comparer = new T();
        }

        /// <summary>
        /// Adds the specified feature...
        /// </summary>
        /// <param name="item">The item.</param>
        /// <exception cref="System.Exception"></exception>
        public new void Add(ColumnFilter item)
        {
            if (!this.Contains(item, m_comparer))
            {
                base.Add(item);
            }
            else
            {
                throw new Exception(string.Format("Errore Table Option Column Filter. \"{0}\": Column Filter già presente !", item.ToString()));
            }
        }
    }
}
